﻿package app.view.components.guiDima 
{
	import app.view.components.guiDima.slideShowD.Image;
	import app.view.events.UIEvent;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import flash.text.TextField;
	import gs.TweenLite;
	
	/**
	 * ...
	 * @author Dmitryi_Koruagin, icq:585466579, dmitryikoruagin@yandex.ru
	 */
	public class PopupHeadDBase extends PopupHeadD
	{
		private var _image:Image;
		
		//	public
		
		//	private
		
		//	const
		
		private var _selected:Boolean;
		private var _id:int;
		//	CONSTRUCTOR
		public function PopupHeadDBase(id:int) 
		{
			_id = id;
			
			init();
		}
		
		//	METHODS
		//	private
		private function init():void
		{
			_image = new Image(popups.imageBgd.width-2,popups.imageBgd.height-2,Image.RESIZE_MAX, Image.ALIGN_CENTER);
			_image.x = popups.imageBgd.x;
			_image.y = popups.imageBgd.y;
			
			popups.addChild(_image);
			
			popups.addChild(popups.imageBgd);
			
			
			roundmask.mouseChildren = false;
			roundmask.mouseEnabled= false;
			
			roundmask.scaleX = roundmask.scaleY = 0;
			popups.mask = roundmask;
			
			
			
			title.miniName.mouseEnabled = false;
			
			popups.text.wordWrap = true;
			popups.text.multiline = true;
			
			/*var t:TextField
			t.multiline=true*/
			
			selected = false;
		}
		
		
		/**
		 * 
		 * @param	str1 - имя
		 * @param	str2 - текст
		 * @param	str3 - урл до картинки
		 */
		public function setParamContent(str1:String='',str2:String='',str3:String=''):void
		{
			
			title.miniName.text = str1;
			popups.namehead.text = str1;
			popups.text.text = str2;
			
			_image.loadImage(str3);
		}
		
		//	public
		public function destroy():void
		{
			title.removeEventListener(MouseEvent.CLICK, onCLickTitle);
			
			_image.destroy();
			
			popups.removeChild(_image);
			
		}
		
		public function get selected():Boolean { return _selected; }
		
		public function set selected(value:Boolean):void 
		{
			_selected = value;
			
			
			if (_selected==false) 
			{
				title.addEventListener(MouseEvent.CLICK, onCLickTitle);
				TweenLite.to(title, 0.5, { alpha: 1 , ease:'none' } );
				title.buttonMode = title.useHandCursor = true;
				TweenLite.to(roundmask, 0.5, { scaleX: 0,scaleY:0 , ease:'none' } );
				
			}else
			{
				title.removeEventListener(MouseEvent.CLICK, onCLickTitle);
				TweenLite.to(title, 0.5, { alpha: 0 , ease:'none' } );
				title.buttonMode = title.useHandCursor = false;
				TweenLite.to(roundmask, 0.5, { scaleX: 1,scaleY:1 , ease:'none' } );
			}
			
		}
		
		public function get id():int { return _id; }
		
		public function set id(value:int):void 
		{
			_id = value;
		}
		
		private function onCLickTitle(e:MouseEvent):void 
		{
			var ev:UIEvent = new UIEvent(UIEvent.CLICK_MINI_POPUPS);
			ev.id = _id;
			dispatchEvent(ev);
		}
		
		//	----------------------------------------------------------------------------------
		
		//	GETTERS/SETTERS
		
		//	----------------------------------------------------------------------------------
		
		//	HANDLERS
	}

}